package com.zking.controller;

import com.zking.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

@Controller
public class MyController2 {
    @RequestMapping("/t3")
    public String t3(Model model) {
        System.out.println("t3----------");
        // return "forward:/t4";
        return "redirect:/t4";
    }
    
    @RequestMapping("/t4")
    public String t4(HttpSession session, Model model) {
        System.out.println("t4----------");
        session.setAttribute("test", "test");
        model.addAttribute("image", "head.jpg");
        return "page";
    }
    
    @RequestMapping("/t5/{id}/search")
    public String t5(
            @PathVariable int id,
            String name,
            Double price,
            Model model) {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("name", name);
        map.put("price", price);
        model.addAttribute("map", map);
        return "page";
    }
}
